package main

import "fmt"

func main() {
	var s string
	var t string

	s = "egg"
	t = "add"

	s = "badc"
	t = "baba"
	v := isIsomorphic(s, t)
	fmt.Println(v)
}

func isIsomorphic(s string, t string) bool {
	sMap := map[byte]byte{}
	tMap := map[byte]byte{}

	sByte := []byte(s)
	tByte := []byte(t)

	if len(tByte) != len(sByte) {
		return false
	}

	for i, b1 := range sByte {
		b2 := tByte[i]

		if sMap[b1] == 0 && tMap[b2] == 0 {
			sMap[b1] = b2
			tMap[b2] = b1
		}
		if sMap[b1] != b2 || tMap[b2] != b1 {
			return false
		}
	}
	return true
}
